package com.ly.spring.mapper;


import lombok.Data;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;


@Repository  // id 默认类名首字母小写 userMapper
@Lazy
@Scope("prototype")
@Primary
@Data
public class UserMapper {

    String myName = "张三";

    public UserMapper() {
        System.out.println("======UserMapper.UserMapper=======" + myName);
    }

    // 构造函数之后执行的方法
    @PostConstruct
    public void init(){
        // 构造函数的java对象的初始化, jvm的初始化
        //  @PostConstruct Spring的初始化,
        //  会在内部属性完成 Spring 注入之后再执行
        System.out.println("======UserMapper.init=======" + myName);
    }

    @PreDestroy
    public void finish(){
        System.out.println("======UserMapper.finish=======" + myName);
    }

    public void login(String name,String pwd){
        System.out.println("======登录=======");
    }
    public String reg(){
        System.out.println("======注册=======");
        return "注册成功";
    }
    public void query(){
        Object s = 100;
        String o = (String) s;
        System.out.println("o = " + o);
        System.out.println("======查询=======");
    }
}
